package com.yiboshi.rehrs.param;

import com.yiboshi.rehrs.common.VarConstant;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Map;

/**
 * @author jack 2025/3/15
 */
@Data
public class ZhongRes<T> {



    @ApiModelProperty(value = "A001成功",position = 1)
    String code;

    @ApiModelProperty(value = "返回obj内容的加密字符",position = 1)
    String data;
    @ApiModelProperty(value = "",position = 2,hidden = true)
    String sign;

    String msg;

    //String time;

    T obj;




    public ZhongRes() {
    }

    public ZhongRes(String code, T obj) {
        this.code = code;
        this.obj = obj;
    }

    public ZhongRes(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static <T> ZhongRes ok() {
        return new ZhongRes(VarConstant.ok_code, null);
    }

    public static <T> ZhongRes ok(T obj) {
        return new ZhongRes(VarConstant.ok_code, obj);
    }

    public static ZhongRes fail(String msg) {
        ZhongRes zhongRes = new ZhongRes();
        zhongRes.setMsg(msg);
        zhongRes.setCode("E002");
        return zhongRes;
    }

    public boolean isOK(){
        return VarConstant.ok_code.equals(this.code)||"A00001".equals(this.code);
    }
}
